<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>computed计算属性</title>
  <script src="../js/vue.min.js"></script>
</head>

<body>
  <div id ="app"> 
    <h2>{{ firstName + ' '+ lastName }}</h2>
    <h2> {{ firstName }} {{ lastName }} </h2>

    <!-- 调用方法进行插值 -->
    <h2> {{ getFullName() }}</h2>

    <!-- 计算属性获取 -->
    <h2> {{ fullName() }} </h2>
    <!-- 简写，去除小括号 -->
    <h2> {{ fullName }} </h2>

  </div>

  <script>
   var vm = new Vue({
    el: '#app',
    data: {
      firstName: "姚",
      lastName: "明"
    },
    // computed：计算属性
    computed: {
      fullName: function() {
        return this.firstName + ' ' + this.lastName;
      }

    },
    methods: {
      getFullName() {
        return this.firstName + ' ' + this.lastName
      }
    }
   });
  </script>
</body>

</html>